import React, { Component } from 'react';
import '../styles/Commodity.css'
import * as service from '../api/index'

class Commodity extends Component {
    constructor(props) {
        super(props);
        this.state = {
            list: []
        }
    }
    async componentDidMount() {
        let res = await service.index_goodlist({page:1,count:12})
        this.setState({ list: res.data.list })
    }
    render() {
        return (
            <div className='commodity'>
                {
                    this.state.list.map((item, index) => {
                        return (
                            <div className="item" key={index}>
                                <img src={item.pic} alt="" />
                                <p>{item.text}</p>
                                <span>原价：{item.salesPrice.name}</span>
                                <div>抢购价：{item.salesPrice.value}</div>
                            </div>
                        )
                    })
                }
            </div>
        );
    }
}

export default Commodity;